package com.baosight.xCyber.model;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 作者 DingMiaoBin:
 * @version 创建时间：Sep 18, 2019 2:31:38 PM
 * <p>
 * 类说明
 */

public class MainNode implements Serializable {
    public String id;
    public String parentId;
    public String showName;
    public String remarkName;

    public List<MainNode> items = new ArrayList<>();

    public List<MainNode> getItems() {
        return items;
    }

    public void setItems(List<MainNode> items) {
        this.items = items;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getShowName() {
        return showName;
    }

    public void setShowName(String showName) {
        this.showName = showName;
    }

    public String getRemarkName() {
        return remarkName;
    }

    public void setRemarkName(String remarkName) {
        this.remarkName = remarkName;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public boolean getIsFinal() {
        if (items == null) {
            return true;
        } else {
            return items.size() == 0 ? true : false;
        }
    }

    @Override
    public String toString() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", id);
        jsonObject.put("showName", showName);
        jsonObject.put("remarkName", remarkName);
        jsonObject.put("parentId", parentId);
        jsonObject.put("items", items);
        boolean isFinal;
        if (items == null) {
            isFinal = true;
        } else {
            isFinal = Boolean.valueOf(this.items.size() == 0);
        }
        jsonObject.put("isFinal", isFinal);
        return jsonObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty);
    }

//	public JSONObject getJsonObject() {
//		JSONObject jsonObject=new JSONObject();
//		jsonObject.put("id", id);
//		jsonObject.put("text",showName);
//		jsonObject.put("showName",showName);
//		jsonObject.put("ptype", "subject");
//		jsonObject.put("insId", null);
//		jsonObject.put("propId", null);
//		jsonObject.put("stno", null);
//		jsonObject.put("serverName", null);
//		jsonObject.put("items", items);
//		return jsonObject;
//	}

}
